﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BLL
{
    public class MenuRoles
    {
        ActionMenu menu;
        public MenuRoles(ActionMenu menu)
        {
            this.menu = menu;
        }

        IMenuRole role;
        public IMenuRole CreateFactry()
        {
            switch (menu)
            {
                case ActionMenu.Evelve:
                    role = new MenuRoleEvelve();
                    break;
                case ActionMenu.Maintain:
                    role = new MenuRoleMaintain();
                    break;
                case ActionMenu.Project:
                    role = new MenuRoleProject();
                    break;
                case ActionMenu.Finance:
                    role = new MenuRoleFinance();
                    break;
                default:
                    role = new MenuRoleRenewal();
                    break;
            }
            return role;
        }
    }

    public enum ActionMenu
    {
        Project,
        Evelve,
        Maintain,
        Renewal,
        Finance
    }

    public interface IMenuRole
    {
        bool IsVisit(string role);
        bool IsEdit(string role);
    }

    /// <summary>
    /// 进展
    /// </summary>
    public class MenuRoleEvelve : IMenuRole
    {
        /// <summary>
        /// 是否可访问
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsVisit(string role)
        {
            return true;
        }

        /// <summary>
        /// 是否可编辑
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsEdit(string role)
        {
            if (role == "非财务客户" || role == "财务客户")
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }

    /// <summary>
    /// 维护保养
    /// </summary>
    public class MenuRoleMaintain : IMenuRole
    {
        /// <summary>
        /// 是否可访问
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsVisit(string role)
        {
            return true;
        }

        /// <summary>
        /// 是否可编辑
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsEdit(string role)
        {
            if (role == "非财务客户" || role == "财务客户")
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }

    /// <summary>
    /// 维修更换
    /// </summary>
    public class MenuRoleRenewal : IMenuRole
    {
        /// <summary>
        /// 是否可访问
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsVisit(string role)
        {
            return true;
        }

        /// <summary>
        /// 是否可编辑
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsEdit(string role)
        {
            if (role == "非财务客户" || role == "财务客户")
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }

    /// <summary>
    /// 维修更换
    /// </summary>
    public class MenuRoleProject : IMenuRole
    {
        /// <summary>
        /// 是否可访问
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsVisit(string role)
        {
            return true;
        }

        /// <summary>
        /// 是否可编辑
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsEdit(string role)
        {
            if (role == "非财务客户" || role == "财务客户")
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }

    /// <summary>
    /// 维修更换
    /// </summary>
    public class MenuRoleFinance : IMenuRole
    {
        /// <summary>
        /// 是否可访问
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsVisit(string role)
        {
            if (role == "非财务客户")
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        /// <summary>
        /// 是否可编辑
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsEdit(string role)
        {
            if (role == "非财务客户" || role == "财务客户")
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
